package com.kotlin.myapplication.mvp.ui.main.fragment

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.kotlin.myapplication.R
import com.kotlin.myapplication.base.BaseFragment
import com.kotlin.myapplication.mvp.ui.main.adapter.ViewPagerAdapter
import com.kotlin.myapplication.mvp.ui.main.fragment.fragment.TabFourFragment
import com.kotlin.myapplication.mvp.ui.main.fragment.fragment.TopFragment
import com.kotlin.myapplication.mvp.ui.main.fragment.fragment.TabThreeFragment
import com.kotlin.myapplication.mvp.ui.main.fragment.fragment.TabTwoFragment

import kotlinx.android.synthetic.main.fragment_square.*

/**
 *@lil
 *@创建时间 2019/11/7 17:40
 *@描述
 */
class SquareFragment : BaseFragment() {

    private val TABS = 4
    var mFragmentList = ArrayList<Fragment>()
    var mViewPagerAdapter: ViewPagerAdapter? = null
    var title: Array<String> = arrayOf("tab1", "tab2", "tab3", "tab4")
    override
    fun getView(inflater: LayoutInflater, parent: ViewGroup): View {
        return inflater.inflate(R.layout.fragment_square, parent, false)
    }

    override fun initView(view: View) {
        title_view.setLeftViewVisible(false)
        title_view.setCenterViewContent("模板")
        mViewPagerAdapter = ViewPagerAdapter(getFragmentManager()!!, initFragment(), title)
        viewPager.adapter = mViewPagerAdapter
        initTab()
    }

    fun initTab() {
        tab_layout.setupWithViewPager(viewPager)
    }

    fun initFragment(): ArrayList<Fragment> {
        mFragmentList.add(TopFragment())
        mFragmentList.add(TabTwoFragment())
        mFragmentList.add(TabThreeFragment())
        mFragmentList.add(TabFourFragment())
        return mFragmentList
    }
}









